<?php

namespace app\beautiful\model;

use app\beautiful\model\mall\GoodsModel;
use app\beautiful\model\project\OnceCardModel;
use app\common\model\CommonModel;



class LevelBenefitsModel extends CommonModel{

    protected  $name = 'beautiful_level_benefits';

    protected  $pk   = 'level_benefits_id';

    public static function onBeforeInsert($model)
    {
        $model->set("add_time", date('Y-m-d H:i:s'));
        $model->set("add_ip", request()->ip());
    }

    public function goods(){

        return  $this->hasOne(GoodsModel::class,'goods_id','goods_id')->field('goods_id,name,category_id');

    }
    public function once_card(){

        return  $this->hasOne(OnceCardModel::class,'once_card_id','once_card_id');

    }
    public function service(){

        return  $this->hasOne(ServiceModel::class,'service_id','service_id');

    }
    public function coupon(){

        return  $this->hasOne(CouponModel::class,'coupon_id','coupon_id');

    }

}

